package com.yuxl.admin.common.graphql.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.graphql.execution.RuntimeWiringConfigurer;

/**
 * GraphQL配置类
 * 用于配置GraphQL相关的bean和自定义标量类型
 */
@Configuration
public class GraphQLConfig {

    private final GraphQLDateTime graphQLDateTime;

    /**
     * 构造函数
     * @param graphQLDateTime 自定义的DateTime标量类型
     */
    public GraphQLConfig(GraphQLDateTime graphQLDateTime) {
        this.graphQLDateTime = graphQLDateTime;
    }

    /**
     * 配置RuntimeWiringConfigurer
     * 用于注册自定义的标量类型
     * @return RuntimeWiringConfigurer实例
     */
    @Bean
    public RuntimeWiringConfigurer runtimeWiringConfigurer() {
        return wiringBuilder -> {
            // 注册自定义的DateTime标量类型
            wiringBuilder.scalar(graphQLDateTime.dateTimeType());
        };
    }
}
